﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.CodeRush.Core;
using System.Drawing;

namespace CR_OrchardHelpers {
    class ActionSmartTagItem : ISmartTagItem {
        private DevExpress.CodeRush.Core.Action _Action;
        private readonly string _FileType;


        public ActionSmartTagItem(string actionName, string fileType) {
            _FileType = fileType;
            _Action = CodeRush.Actions.Get(actionName);
        }

        #region ISmartTagItem Members

        public string Caption {
            get {
                return _FileType;
            }
            //get {
            //    return _Action != null ? _Action.ActionName : String.Empty;
            //}
        }

        public void Execute() {
            if (_Action != null)
                _Action.DoExecute(_FileType);
        }

        public string GetContextString() {
            return String.Empty;
        }

        public ISmartTagItem GetSubMenuItem(string name) {
            return null;
        }

        public ISmartTagItem[] GetSubMenuItems() {
            return null;
        }

        public bool HasSubMenuItems {
            get { return false; }
        }

        public void HidePreview(Rectangle rectangle) {

        }

        public string HintCaption {
            get {
                return _Action != null ? _Action.ActionName : String.Empty;
            }
        }

        public string HintText {
            get {
                return _Action != null ? _Action.Description : String.Empty;
            }
        }

        public Bitmap Image { get; set; }
        public Color ImageBackColor { get; set; }

        public SmartTagItemType ItemType {
            get { return SmartTagItemType.Default; }
        }

        public string Name {
            get { return _Action != null ? _Action.ActionName : String.Empty; }
        }

        public SmartTagProviderBase Provider { get; set; }

        public void SelectMenuItem(ISmartTagItem item) {

        }

        public void ShowPreview(Rectangle rectangle, out Rectangle[] rectangles, out HintSurface legend) {
            rectangles = new Rectangle[0];
            legend = null;
        }

        public void ShowPreview(Rectangle rectangle) {

        }

        public TransparentBitmap TransparentBitmap {
            get { return null; }
        }

        public string ParentMenu { get; set; }

        public bool ShowBigHint {
            get { return false; }
        }
        #endregion
    }
}
